package com.lg.happyfarmer.bean;

import com.hemaapp.hm_FrameWork.HemaUser;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

import xtom.frame.exception.DataParseException;

/**
 * 用户信息(注意User信息必须继承HemaUser,并且User中不用再包含token字段)
 */
public class User extends HemaUser implements Serializable {
    private static final long serialVersionUID = 1L;

    private String id;
    private String username;
    private String email;
    private String nickname;
    private String mobile;
    private String password;
    private String charindex;
    private String sex;
    private String age;// 年龄
    private String selfsign;// 签名
    private String avatar;
    private String avatarbig;
    private String district_name;
    private String address;
    private String lng;//经度
    private String lat;//纬度
    private String regdate;//用户注册时间
    private String score;//粮票
    private String role;//角色	0普通用户 1田家用户
    private String authflag;//田家身份审核中	0否 1是
    private String land_id;//土地主键
    private String feeaccount; //账户余额
    private String noticecount;//未读消息数量
    private String codeurl;//个人推荐二维码
    private String token;// 登陆令牌	由系统随机生成，作为后续请求服务的必传字段。
    private String android_must_update;// 安卓强制更新标记
    //0：不强制 1：强制
    //（当软件架构进行了较大变动，客户端必须强制用户升级到最新版本）
    private String android_last_version;// 安卓最新版本号	将该信息与安卓本机版本号比对，如果不相等，则提醒在线升级
    private String android_update_url;// 安卓软件更新地址
    //商城项目中，多设计如下5个字段，方便用户提现
    private String bankuser; //户主姓名
    private String bankname; //开户行名称
    private String bankcard; //银行卡号
    private String bankaddress; //开户行地址
    private String alipay; //支付宝帐号
    private String level_score;// 个人等级分数
    private String couponCost;//粮票的总花费
    private String couponGain;//粮票的总获得的数量
    private String saleContent;
    private String farmer_agent;//农户经纪人标志 	0否;1是
    private boolean isIndex = false;//是否首页点击成为农户经纪人跳转 true 是 false 否；


    public User(JSONObject jsonObject) throws DataParseException {
        super(jsonObject);
        if (jsonObject != null) {
            try {
                id = get(jsonObject, "id");
                username = get(jsonObject, "username");
                email = get(jsonObject, "email");
                password = get(jsonObject, "password");
                age = get(jsonObject, "age");
                nickname = get(jsonObject, "nickname");
                charindex = get(jsonObject, "charindex");
                sex = get(jsonObject, "sex");
                mobile = get(jsonObject, "mobile");
                avatar = get(jsonObject, "avatar");
                avatarbig = get(jsonObject, "avatarbig");
                district_name = get(jsonObject, "district_name");
                lng = get(jsonObject, "lng");
                lat = get(jsonObject, "lat");
                regdate = get(jsonObject, "regdate");
                score = get(jsonObject, "score");
                role = get(jsonObject, "role");
                authflag = get(jsonObject, "authflag");

                land_id = get(jsonObject, "land_id");
                feeaccount = get(jsonObject, "feeaccount");
                noticecount = get(jsonObject, "noticecount");
                codeurl = get(jsonObject, "codeurl");
                token = get(jsonObject, "token");
                selfsign = get(jsonObject, "selfsign");
                android_must_update = get(jsonObject, "android_must_update");
                android_last_version = get(jsonObject, "android_last_version");
                android_update_url = get(jsonObject, "android_update_url");

                bankuser = get(jsonObject, "bankuser");
                bankname = get(jsonObject, "bankname");
                bankcard = get(jsonObject, "bankcard");
                bankaddress = get(jsonObject, "bankaddress");
                alipay = get(jsonObject, "alipay");
                level_score = get(jsonObject, "level_score");
                farmer_agent = get(jsonObject, "farmer_agent");

                log_i(toString());
            } catch (JSONException e) {
                throw new DataParseException(e);
            }
        }
    }

    public User(String nickname, String address, String token, String saleContent) {
        super(token);
        this.nickname = nickname;
        this.address = address;
        this.saleContent = saleContent;
    }

    public User(
            String id, String username, String email, String nickname, String mobile,
            String password, String charindex, String sex, String age, String avatar,
            String avatarbig, String district_name, String lng, String lat,
            String regdate, String score, String role, String authflag, String land_id, String feeaccount,
            String token, String android_must_update, String android_last_version,
            String android_update_url, String bankuser, String bankname,
            String bankcard, String bankaddress, String alipay, String codeurl, String level_score, String farmer_agent) {
        super(token);
        this.id = id;
        this.username = username;
        this.email = email;
        this.nickname = nickname;
        this.mobile = mobile;
        this.password = password;
        this.charindex = charindex;
        this.sex = sex;
        this.age = age;
        this.avatar = avatar;
        this.avatarbig = avatarbig;
        this.district_name = district_name;
        this.lng = lng;
        this.lat = lat;
        this.regdate = regdate;
        this.score = score;
        this.role = role;
        this.authflag = authflag;
        this.land_id = land_id;
        this.feeaccount = feeaccount;
        this.token = token;
        this.android_must_update = android_must_update;
        this.android_last_version = android_last_version;
        this.android_update_url = android_update_url;

        this.bankuser = bankuser;
        this.bankname = bankname;
        this.bankcard = bankcard;
        this.bankaddress = bankaddress;
        this.alipay = alipay;

        this.codeurl = codeurl;
        this.level_score = level_score;

        this.farmer_agent = farmer_agent;
    }

    public String getAddress() {
        return address;
    }

    public boolean isIndex() {
        return isIndex;
    }

    public void setIndex(boolean index) {
        isIndex = index;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getSaleContent() {
        return saleContent;
    }

    public void setSaleContent(String saleContent) {
        this.saleContent = saleContent;
    }

    public String getFarmer_agent() {
        return farmer_agent;
    }

    @Override
    public String toString() {
        return "User [id=" + id + ", username=" + username + ", email=" + email
                + ", nickname=" + nickname + ", mobile=" + mobile
                + ", password=" + password + ", charindex=" + charindex
                + ", sex=" + sex + ", age=" + age + ", avatar=" + avatar
                + ", avatarbig=" + avatarbig + ", district_name="
                + district_name + ", lng=" + lng + ", lat=" + lat
                + ", regdate=" + regdate + ", score=" + score + ", role="
                + role + ", authflag=" + authflag + ", land_id=" + land_id
                + ", feeaccount=" + feeaccount + ", noticecount=" + noticecount
                + ", codeurl=" + codeurl + ", token=" + token
                + ", android_must_update=" + android_must_update
                + ", android_last_version=" + android_last_version
                + ", android_update_url=" + android_update_url + ", bankuser="
                + bankuser + ", bankname=" + bankname + ", bankcard="
                + bankcard + ", bankaddress=" + bankaddress + ", alipay="
                + alipay + ", level_score=" + level_score + ", couponCost="
                + couponCost + ", couponGain=" + couponGain + "]";
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getSelfsign() {
        return selfsign;
    }

    public void setSelfsign(String selfsign) {
        this.selfsign = selfsign;
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @return the username
     */
    public String getUsername() {
        return username;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the nickname
     */
    public String getNickname() {
        return nickname;
    }

    /**
     * @return the mobile
     */
    public String getMobile() {
        return mobile;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @return the charindex
     */
    public String getCharindex() {
        return charindex;
    }

    /**
     * @return the sex
     */
    public String getSex() {
        return sex;
    }

    /**
     * @return the age
     */
    public String getAge() {
        return age;
    }

    /**
     * @return the avatar
     */
    public String getAvatar() {
        return avatar;
    }

    /**
     * @return the avatarbig
     */
    public String getAvatarbig() {
        return avatarbig;
    }

    /**
     * @return the district_name
     */
    public String getDistrict_name() {
        return district_name;
    }

    /**
     * @return the lng
     */
    public String getLng() {
        return lng;
    }

    /**
     * @return the lat
     */
    public String getLat() {
        return lat;
    }

    /**
     * @return the regdate
     */
    public String getRegdate() {
        return regdate;
    }

    /**
     * @return the score
     */
    public String getRole() {
        return role;
    }

    /**
     * @return the authflag
     */
    public String getAuthflag() {
        return authflag;
    }

    /**
     * @return the 土地以主键
     */
    public String getLand_id() {
        return land_id;
    }

    /**
     * @return the 土地以主键
     */
    public void setLand_id(String land_id) {
        this.land_id = land_id;
    }

    /**
     * @return the score
     */
    public String getScore() {
        return score;
    }

    /**
     * @return the bankuser
     */
    public String getandroid_must_update() {
        return android_must_update;
    }

    public String getandroid_last_version() {
        return android_last_version;
    }

    public String getandroid_update_url() {
        return android_update_url;
    }

    public String getBankuser() {
        return bankuser;
    }

    public String getBankname() {
        return bankname;
    }

    public String getBankcard() {
        return bankcard;
    }

    public String getBankaddress() {
        return bankaddress;
    }

    public void setBankuser(String bankuser) {
        this.bankuser = bankuser;
    }

    public void setBankname(String bankname) {
        this.bankname = bankname;
    }

    public void setBankcard(String bankcard) {
        this.bankcard = bankcard;
    }

    public void setBankaddress(String bankaddress) {
        this.bankaddress = bankaddress;
    }

    public String getAlipay() {
        return alipay;
    }

    public void setAlipay(String alipay) {
        this.alipay = alipay;
    }

    public String getFeeaccount() {
        return feeaccount;
    }

    public void setFeeaccount(String feeaccount) {
        this.feeaccount = feeaccount;
    }

    public String getNoticecount() {
        return noticecount;
    }

    public void setNoticecount(String noticecount) {
        this.noticecount = noticecount;
    }

    public String getCouponCost() {
        return couponCost;
    }

    public void setCouponCost(String couponCost) {
        this.couponCost = couponCost;
    }

    public String getCouponGain() {
        return couponGain;
    }

    public void setCouponGain(String couponGain) {
        this.couponGain = couponGain;
    }

    public String getLevel_score() {
        return level_score;
    }

    public String getCodeurl() {
        return codeurl;
    }

    public void setFarmer_agent(String farmer_agent) {
        this.farmer_agent = farmer_agent;
    }
}
